package com.yoso.base.pojo;

import com.yoso.base.infrastructure.constants.PageConstants;
import lombok.Data;

/**
 * 分页参数
 *
 * @author shizejin
 */
@Data
public class PagePojo {
    /**
     * 当前页
     */
    private int curPage = PageConstants.CUR_PAGE;
    /**
     * 单页条数
     */
    private int pageSize = PageConstants.PAGE_SIZE;
    /**
     * 总条数
     */
    private int total;
    /**
     * 尾页（总页数）
     */
    private int pageCount;

    public static PagePojo of(int curPage, int pageSize) {
        PagePojo page = new PagePojo();
        page.setCurPage(curPage);
        page.setPageSize(pageSize);
        return page;
    }

    public int getPageCount() {
        if (this.total > 0) {
            pageCount = total / pageSize;
            if (total % pageSize > 0) {
                ++pageCount;
            }
        }
        return this.pageCount;
    }
}
























